package org.wzl._360mallbackend.utils;

import java.util.HashMap;
import java.util.Map;

import lombok.Data;

@Data
public class Response {

    private Map<String, Object> data = new HashMap<>();
    private Integer code;
    private String msg;

    public static Response ok(String msg, Map<String, Object> map) {
        Response r = new Response();
        r.data = map;
        r.code = 200;
        r.msg = msg;
        return r;
    }

    public static Response ok(String msg) {
        Response r = new Response();
        r.code = 200;
        r.msg = msg;
        return r;
    }

    public static Response ok() {
        Response r = new Response();
        r.code = 200;
        return r;
    }

    public static Response fail(String msg) {
        Response r = new Response();
        r.code = 400;
        r.msg = msg;
        return r;
    }

    public static Response fail() {
        Response r = new Response();
        r.code = 400;
        return r;
    }

    public Response putData(String k, Object data) {
        this.data.put(k, data);
        return this;
    }


}
